<template>
  <view>
    <view class="footer-box" :class="{ 'footer-box2': safe }">
      <slot name="footer-h"></slot>
      <view class="btn">
        <slot name="footer-l" class="footer-l"></slot>
        <button
          class="center"
          @tap="$u.debounce(btnClick, 500)"
          :style="{
            background: btnStyle.backgroundColor
              ? btnStyle.backgroundColor
              : btnStyle.background,
            color: btnStyle.color,
            'border-color':btnStyle.borderColor
          }"
        >
          {{ buttonText }}
        </button>
        <!-- <button class="center" @tap="btnClick" >{{buttonText}}</button> -->
        <slot name="footer-b" class="footer-b"></slot>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'BaseFootButton',
  props: {
    safe: {},
    buttonText: {
      type: String,
      default: '',
    },
    btnStyle: {
      type: Object,
      default: () => {
        return {
          backgroundColor: '#f5f5f5',
          borderColor:"#fff"
        }
      },
    },
  },
  data() {
    return {}
  },
  methods: {
    btnClick() {
      this.$emit('btnClick')
    },
  },
}
</script>

<style lang="scss" scoped>
.footer-box {
  z-index: 999;
  width: 100vw;
  min-height: 110rpx;
  position: fixed;

  background: #ffffff;
  // box-shadow: 0px 0px 16rpx 0px rgba(0, 0, 0, 0.1);
  padding: 20rpx 32rpx;
  display: flex;
  flex-direction: column;

  bottom: calc(env(safe-area-inset-bottom) - 6rpx);

  .btn {
    display: flex;
    justify-content: space-between;
    .footer-b {
      width: 100%;
      flex: 1;
    }
  }
  .center {
    width: 100%;
    height: 100%;
    height: 80rpx;
    border-radius: 40rpx;
    color: #666666;
    font-size: 32rpx;
    font-weight: 500;
    border: 1px solid #fff;
    box-sizing: border-box;
    // background-color: #FF5900;
  }

  .center::after {
    border: none;
  }
}
.footer-box2 {
  padding-bottom: calc(env(safe-area-inset-bottom) - 6rpx);
  bottom: 0;
}
</style>
